home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_bas / vbint.zip / INTDEMO.FRM < prev    next >
Text File  |  1994-06-04  |  13KB  |  533 lines

  1. VERSION 2.00
  2. Begin Form IntDemo 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "DOS Interrupt Test"
  5.    ClientHeight    =   5295
  6.    ClientLeft      =   990
  7.    ClientTop       =   1470
  8.    ClientWidth     =   7005
  9.    Height          =   5700
  10.    Icon            =   INTDEMO.FRX:0000
  11.    Left            =   930
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5295
  14.    ScaleWidth      =   7005
  15.    Top             =   1125
  16.    Width           =   7125
  17.    Begin CommandButton bCmd 
  18.       Caption         =   "Dir &Listing"
  19.       Height          =   495
  20.       Index           =   6
  21.       Left            =   5280
  22.       TabIndex        =   5
  23.       Top             =   3060
  24.       Width           =   1545
  25.    End
  26.    Begin Timer Timer1 
  27.       Enabled         =   0   'False
  28.       Interval        =   750
  29.       Left            =   4500
  30.       Top             =   30
  31.    End
  32.    Begin CommandButton bCmd 
  33.       Caption         =   "Dir &Tree"
  34.       Height          =   495
  35.       Index           =   4
  36.       Left            =   5280
  37.       TabIndex        =   4
  38.       Top             =   2490
  39.       Width           =   1545
  40.    End
  41.    Begin ListBox List1 
  42.       FontBold        =   0   'False
  43.       FontItalic      =   0   'False
  44.       FontName        =   "MS Sans Serif"
  45.       FontSize        =   8.25
  46.       FontStrikethru  =   0   'False
  47.       FontUnderline   =   0   'False
  48.       Height          =   4125
  49.       Left            =   300
  50.       TabIndex        =   9
  51.       Top             =   960
  52.       Visible         =   0   'False
  53.       Width           =   4635
  54.    End
  55.    Begin CommandButton bCmd 
  56.       Caption         =   "&FindFirst/Next"
  57.       Height          =   495
  58.       Index           =   3
  59.       Left            =   5280
  60.       TabIndex        =   3
  61.       Top             =   1920
  62.       Width           =   1545
  63.    End
  64.    Begin TextBox Text1 
  65.       Height          =   345
  66.       Left            =   300
  67.       TabIndex        =   8
  68.       Text            =   "Text1"
  69.       Top             =   480
  70.       Visible         =   0   'False
  71.       Width           =   4635
  72.    End
  73.    Begin CommandButton bCmd 
  74.       Caption         =   "D&OS ""Stuff"""
  75.       Height          =   495
  76.       Index           =   2
  77.       Left            =   5280
  78.       TabIndex        =   0
  79.       Top             =   210
  80.       Width           =   1545
  81.    End
  82.    Begin CommandButton bCmd 
  83.       Cancel          =   -1  'True
  84.       Caption         =   "E&xit"
  85.       Height          =   495
  86.       Index           =   5
  87.       Left            =   5280
  88.       TabIndex        =   6
  89.       Top             =   4590
  90.       Width           =   1545
  91.    End
  92.    Begin CommandButton bCmd 
  93.       Caption         =   "Get &Space"
  94.       Height          =   495
  95.       Index           =   1
  96.       Left            =   5280
  97.       TabIndex        =   1
  98.       Top             =   780
  99.       Width           =   1545
  100.    End
  101.    Begin CommandButton bCmd 
  102.       Caption         =   "Get Cur&Dirs"
  103.       Height          =   495
  104.       Index           =   0
  105.       Left            =   5280
  106.       TabIndex        =   2
  107.       Top             =   1350
  108.       Width           =   1545
  109.    End
  110.    Begin Image Image1 
  111.       Height          =   975
  112.       Left            =   5520
  113.       Stretch         =   -1  'True
  114.       Top             =   3600
  115.       Width           =   1065
  116.    End
  117.    Begin Label Label1 
  118.       AutoSize        =   -1  'True
  119.       Caption         =   "Label1"
  120.       Height          =   195
  121.       Left            =   300
  122.       TabIndex        =   7
  123.       Top             =   210
  124.       Visible         =   0   'False
  125.       Width           =   585
  126.    End
  127. End
  128. '---------------------------------------------------------------------------
  129. ' DOS Interrupt Demo Program, Copyright (c) 1994 Karl E. Peterson
  130. ' Redistributed by permission.
  131. '
  132. ' Requires: VBInt.DLL, VBRun300.DLL
  133. '
  134. ' This program may be distributed freely on the condition that it is
  135. ' distributed in full, and unmodified, and that no fee is charged for such
  136. ' distribution with the exception of reasonable media and shipping charges.
  137. ' Any or all portions of the source code may be incorporated into your own
  138. ' programs, and those programs may be distributed without payment of
  139. ' royalties on the condition that such programs differ substantially from
  140. ' this demonstration program.
  141. '
  142. ' This program is distributed AS IS.  The author acknowledges absolutely
  143. ' no liability for its use or misuse.  The sole purpose of this program is to
  144. ' demonstrate some of the powerful capabilities of VBInt.DLL, written and
  145. ' copyrighted by Rick Esterling.  Calling DOS interrupts from Windows is
  146. ' fairly "non-standard" behavior.  Users of this program acknowledge that
  147. ' they are doing so at their OWN RISK.
  148. '
  149. ' This demonstration program was created and distributed by:
  150. '   Karl E. Peterson
  151. '   Regional Transportation Council
  152. '   1351 Officers' Row
  153. '   Vancouver, Washington 98661
  154. '   CompuServe: 72302,3707
  155. '
  156. ' Your comments or questions are invited!
  157. '---------------------------------------------------------------------------
  158.  
  159. Option Explicit
  160. DefInt A-Z
  161.  
  162. Const bDirs = 0
  163. Const bSpace = 1
  164. Const bDOS = 2
  165. Const bFind = 3
  166. Const bTree = 4
  167. Const bList = 6
  168. Const bExit = 5
  169.  
  170. Dim DtaEstablished%
  171.  
  172. Sub bCmd_Click (Index As Integer)
  173.  
  174.   Screen.MousePointer = 11
  175.   Cls
  176.   Select Case Index
  177.     Case bDirs, bSpace, bDOS, bExit
  178.       Text1.Visible = False
  179.       Label1.Visible = False
  180.       List1.Visible = False
  181.       Select Case Index
  182.         Case bDirs: ShowCurrentDirs
  183.         Case bSpace: ShowFreeSpace
  184.         Case bDOS: ShowDosStuff
  185.         Case bExit: Unload Me
  186.       End Select
  187.  
  188.     Case bFind
  189.       List1.Visible = False
  190.       Text1 = "C:\*.*"
  191.       Text1.Visible = True
  192.       Label1 = "FileSpec to Find (press Enter for each match):"
  193.       Label1.Visible = True
  194.       Text1.SetFocus
  195.       Text1.SelStart = 0
  196.       Text1.SelLength = Len(Text1)
  197.       Timer1.Enabled = True
  198.       DtaEstablished = False
  199.     
  200.     Case bTree, bList
  201.       Text1.Visible = True
  202.       Label1.Visible = True
  203.       List1.Visible = True
  204.       Select Case Index
  205.         Case bTree
  206.           Text1 = "C:"
  207.           Label1 = "Drive to Search (press Enter to begin scan):"
  208.           Refresh
  209.           ShowDirTree (Text1), List1
  210.         Case bList
  211.           Text1 = "C:\"
  212.           Label1 = "Directory to Search (press Enter to begin scan):"
  213.           Refresh
  214.           ShowDirList (Text1), List1
  215.       End Select
  216.       Text1.SetFocus
  217.       Text1.SelStart = 0
  218.       Text1.SelLength = Len(Text1)
  219.     
  220.   End Select
  221.   Screen.MousePointer = 0
  222. End Sub
  223.  
  224. Sub Form_Load ()
  225.   
  226.   Dim Proceed%, m$
  227.   Proceed = IDYES
  228.   If WinIsNT() Then
  229.     m$ = "Running under Windows NT!" + Chr$(13) + Chr$(10)
  230.     m$ = m$ + "Do you wish to continue?"
  231.     Proceed = MsgBox(m$, MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON2, "Warning")
  232.   End If
  233.   
  234.   If Proceed = IDYES Then
  235.     DosVersion = DosGetVersion()
  236.     Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
  237.     SetTabs List1
  238.     Show
  239.     bCmd_Click bDOS
  240.   Else
  241.     Unload Me
  242.   End If
  243.  
  244.   Image1.Picture = Me.Icon
  245.  
  246. End Sub
  247.  
  248. Sub SetColor (Bold%)
  249.   If Bold Then
  250.     ForeColor = &H80000008
  251.   Else
  252.     ForeColor = RGB(128, 128, 128)
  253.   End If
  254. End Sub
  255.  
  256. Sub SetTabs (Lst As ListBox)
  257.   
  258.   ReDim Tabs(0 To 4) As Integer
  259.   Dim Rtn%
  260.   Tabs(0) = 60
  261.   Tabs(1) = 100
  262.   Tabs(2) = 140
  263.   Tabs(3) = 180
  264.   Tabs(4) = 220
  265.   Rtn = SendMessage(Lst.hWnd, LB_SETTABSTOPS, 5, Tabs(0))
  266.   
  267. End Sub
  268.  
  269. Sub ShowCurrentDirs ()
  270.  
  271.   Dim i%, CurrDir$
  272.   Cls
  273.   For i = 1 To 26
  274.     ForeColor = RGB(128, 0, 0)
  275.     If DrvRemovable(Chr$(i + 64)) Then
  276.       Print "* ";
  277.     ElseIf DrvCDRom(Chr$(i + 64)) Then
  278.       Print "[CD]";
  279.     End If
  280.     
  281.     If DrvGetDir(Chr$(i + 64), CurrDir$) Then
  282.       ForeColor = RGB(0, 0, 128)
  283.       Print "{" + DrvGetVolume$(Chr$(i + 64)) + "}  ";
  284.       If DrvRemote(Chr$(i + 64)) Then
  285.         ForeColor = RGB(0, 128, 0)
  286.       Else
  287.         ForeColor = RGB(0, 0, 0)
  288.       End If
  289.       Print Chr$(i + 64) + ":" + CurrDir$
  290.     Else
  291.       ForeColor = RGB(128, 128, 128)
  292.       Print Chr$(i + 64) + ": -->" + CurrDir$
  293.     End If
  294.   Next i
  295.   
  296.   ForeColor = RGB(128, 0, 0)
  297.   Print "* -- Removable Media   ";
  298.   ForeColor = RGB(0, 0, 128)
  299.   Print "{Volume Label}   ";
  300.   ForeColor = RGB(0, 128, 0)
  301.   Print "Remote Drive"
  302.   ForeColor = RGB(0, 0, 0)
  303.  
  304. End Sub
  305.  
  306. Sub ShowDirList (DirSpec$, Lst As ListBox)
  307.  
  308.   Dim Files() As FileDataType
  309.   Dim i%
  310.   Screen.MousePointer = 11
  311.     Lst.Clear
  312.     Lst.Refresh
  313.     If Right$(DirSpec$, 1) <> "\" Then
  314.       DirSpec$ = DirSpec$ + "\*.*"
  315.     Else
  316.       DirSpec$ = DirSpec$ + "*.*"
  317.     End If
  318.     i = FillDirArray(DirSpec$, Files(), attrAllNorm, False, False)
  319.     If i Then
  320.       Lst.AddItem DosErrorMsg$(i)
  321.     Else
  322.       For i = LBound(Files) To UBound(Files)
  323.         Lst.AddItem FmtDirEntry$(Files(i))
  324.       Next i
  325.     End If
  326.   Screen.MousePointer = 0
  327.  
  328. End Sub
  329.  
  330. Sub ShowDirTree (Drive$, Lst As ListBox)
  331.  
  332.   Dim Dirs() As String
  333.   Dim i%
  334.   Screen.MousePointer = 11
  335.     Lst.Clear
  336.     Lst.Refresh
  337.     FillDirTreeArray Dirs(), UCase$(Left$(Drive$, 1)) + ":\", 0
  338.     For i = LBound(Dirs) To UBound(Dirs)
  339.       Lst.AddItem Dirs(i)
  340.     Next i
  341.   Screen.MousePointer = 0
  342.  
  343. End Sub
  344.  
  345. Sub ShowDosStuff ()
  346.   
  347.   Cls
  348.   Print "DOS Version " & Format$(DosVersion / 100, "#0.00")
  349.   
  350.   If DosAnsiLoaded() Then
  351.     SetColor 1
  352.     Print "Ansi Loaded"
  353.   Else
  354.     SetColor 0
  355.     Print "Ansi NOT Loaded"
  356.   End If
  357.  
  358.   If DosAppendLoaded() Then
  359.     SetColor 1
  360.     Print "Append Loaded"
  361.   Else
  362.     SetColor 0
  363.     Print "Append NOT Loaded"
  364.   End If
  365.  
  366.   If DosAssignLoaded() Then
  367.     SetColor 1
  368.     Print "Assign Loaded"
  369.   Else
  370.     SetColor 0
  371.     Print "Assign NOT Loaded"
  372.   End If
  373.  
  374.   If DosDblSpaceLoaded() Then
  375.     SetColor 1
  376.     Print "DblSpace Loaded"
  377.   Else
  378.     SetColor 0
  379.     Print "DblSpace NOT Loaded"
  380.   End If
  381.  
  382.   If DosDosKeyLoaded() Then
  383.     SetColor 1
  384.     Print "DosKey Loaded"
  385.   Else
  386.     SetColor 0
  387.     Print "DosKey NOT Loaded"
  388.   End If
  389.  
  390.   If DosHimemLoaded() Then
  391.     SetColor 1
  392.     Print "HiMem Loaded"
  393.   Else
  394.     SetColor 0
  395.     Print "HiMem NOT Loaded"
  396.   End If
  397.  
  398.   If DosGraftablLoaded() Then
  399.     SetColor 1
  400.     Print "GrafTabl Loaded"
  401.   Else
  402.     SetColor 0
  403.     Print "GrafTabl NOT Loaded"
  404.   End If
  405.  
  406.   If DosNetworkLoaded() Then
  407.     SetColor 1
  408.     Print "Network Loaded"
  409.   Else
  410.     SetColor 0
  411.     Print "Network NOT Loaded"
  412.   End If
  413.  
  414.   If DosNlsfuncLoaded() Then
  415.     SetColor 1
  416.     Print "NlsFunc Loaded"
  417.   Else
  418.     SetColor 0
  419.     Print "NlsFunc NOT Loaded"
  420.   End If
  421.  
  422.   If DosPrintLoaded() Then
  423.     SetColor 1
  424.     Print "Print Loaded"
  425.   Else
  426.     SetColor 0
  427.     Print "Print NOT Loaded"
  428.   End If
  429.  
  430.   If DosShareLoaded() Then
  431.     SetColor 1
  432.     Print "Share Loaded"
  433.   Else
  434.     SetColor 0
  435.     Print "Share NOT Loaded"
  436.   End If
  437.   SetColor 1
  438.  
  439. End Sub
  440.  
  441. Sub ShowFileFound (Txt As TextBox, First%)
  442.  
  443.   Static DTA As DTAType
  444.   Dim File As FileDataType
  445.   Dim ErrorCode%, Rtn%
  446.   
  447.   If First Then
  448.     Rtn = FileFindFirst((Txt), DTA, attrAllFile, ErrorCode)
  449.   Else
  450.     Rtn = FileFindNext(DTA, attrAllFile, ErrorCode)
  451.   End If
  452.   
  453.   Cls
  454.   CurrentY = Txt.Top + Txt.Height * 1.25
  455.   CurrentX = Txt.Left
  456.   If ErrorCode Then
  457.     Print DosErrorMsg$(ErrorCode)
  458.     DtaEstablished = False
  459.   Else
  460.     FileGetData DTA, File
  461.     Print File.FileName
  462.     CurrentX = Txt.Left
  463.     Print Format$(File.Size, "#,##0"); " bytes"
  464.     CurrentX = Txt.Left
  465.     Print Format$(File.sDate, "long date")
  466.     CurrentX = Txt.Left
  467.     Print Format$(File.sDate, "long time")
  468.     DtaEstablished = True
  469.   End If
  470.   
  471.   Txt.SelStart = 0
  472.   Txt.SelLength = Len(Txt)
  473.  
  474. End Sub
  475.  
  476. Sub ShowFreeSpace ()
  477.   
  478.   Dim i%, d$, sn$
  479.   Dim disk As DiskFreeSpaceType
  480.   Cls
  481.   For i = 1 To 26
  482.     d$ = Chr$(i + 64) + ":  "
  483.     DrvFreeSpace d$, disk
  484.     If disk.totalBytes Then
  485.       Print d$;
  486.       If DrvCDRom(Chr$(i + 64)) Then
  487.         Print "[CD-ROM]  0 of ";
  488.       Else
  489.         Print Format$(disk.availableBytes, "#,##0");
  490.         Print " of ";
  491.       End If
  492.       Print Format$(disk.totalBytes, "#,##0"); " free  ";
  493.       If DrvGetSerNum(d$, sn$) Then
  494.         Print "S/N:"; sn$
  495.       Else
  496.         Print
  497.       End If
  498.     End If
  499.   Next i
  500.  
  501. End Sub
  502.  
  503. Sub Text1_Change ()
  504.   Timer1.Enabled = False
  505.   DtaEstablished = False
  506. End Sub
  507.  
  508. Sub Text1_KeyPress (KeyAscii As Integer)
  509.   
  510.   If KeyAscii = 13 Then 'Enter
  511.     KeyAscii = 0
  512.     If InStr(Label1, "FileSpec") Then
  513.       Dim First%
  514.       If Not DtaEstablished Then First = True
  515.       ShowFileFound Text1, First
  516.     ElseIf InStr(Label1, "Drive") Then
  517.       ShowDirTree (Text1), List1
  518.     Else
  519.       ShowDirList (Text1), List1
  520.     End If
  521.   End If
  522.  
  523. End Sub
  524.  
  525. Sub Timer1_Timer ()
  526.  
  527.   If ActiveControl Is Text1 Then
  528.     SendKeys "{Enter}"
  529.   End If
  530.  
  531. End Sub
  532.  
  533.